class Solution:
    def combine(self, n, k):
        lst = []
        l = []
        r = 0
        left = range(1, n+1)
        self.comb(lst, l, left, r, k)
        return lst
    def comb(self, lst, l, left, r, k):
        if k == 1:
            for i in range(r, len(left)):
                lst.append(l+[left[i]])
            return
        for i in range(r, len(left)):
            tmp_l = list(l)
            tmp_l.append(left[i])
            self.comb(lst, tmp_l, left, i+1, k-1)

n = 5
k = 2
ss = Solution()
lst = ss.combine(n,k)
for i in range(len(lst)):
    print lst[i]
